<?php


if (isset($_GET['room']) &&
    isset($_GET['user']) &&
    isset($_GET['pass']) &&
    isset($_GET['mptr']))
{
  include_once 'init.php';
  $modified = unlog_users();

  if ($chat_data['kick'][$_GET['user']] ||
      $chat_data['kick'][$_SERVER['REMOTE_ADDR']])
  {
    echo "-\r\n";
    die;
  }

  if (isset($chat_data['user'][$_GET['user']]) &&
      isset($chat_data['pass'][$_GET['user']]) &&
           ($chat_data['pass'][$_GET['user']]) == $_GET['pass'])
       echo "+\r\n";
  else echo "-\r\n";

  foreach ($chat_data['data'] as $i => $x)
    if ($i > $_GET['mptr'])
      if (!is_array($x))
           echo "$i\r\n$x\r\n";
      else if ($x['priv'] != '.' && $x['user'] == $_GET['user'] ||
               $x['priv'] != '.' && $x['priv'] == $_GET['user'] ||
               $x['priv'] == '.' && $x['room'] == $_GET['room'])
             echo "$i\r\n{$x['data']}\r\n" . (time()-$x['time']) . "\r\n";

  if ($modified) file_put_contents('data.txt', serialize($chat_data));
}

?>